﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;

namespace PhotoGallery
{
    public class Routing
    {
        public static IRouteBuilder ConfigureRoutes(IRouteBuilder routeBuilder)
        {
            AddDefaultRoute(routeBuilder, defaultController: "Home", defaultAction: "Index");
            return routeBuilder;
        }

        private static void AddDefaultRoute(IRouteBuilder routeBuilder, string defaultController, string defaultAction)
        {
            //routeBuilder.MapRoute(
            //    name: "default",
            //    template: "{controller=Home}/{action=Index}/{id?}",
            //    defaults: new
            //    {
            //        controller = defaultController,
            //        action = defaultAction,
            //    });
            routeBuilder.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
            routeBuilder.MapRoute(name: "areas", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
        }
    }
}